package com.nsession.common;

import lombok.Data;
import lombok.Getter;

/**
 * 错误定义
 * User: Terence
 * Date: 2014/6/16
 * Time: 15:29
 */
public enum ErrorDef {
    /**
     * 系统异常
     */
    SYSTEM_ERROR("999999", "系统异常"),
    /**
     * 成功
     */
    SUCCESS("000000", "成功");

    @Getter
    private String code;

    @Getter
    private String desc;

    public static final String PREFIX = "NSESSION";


    private ErrorDef(String code, String desc) {
        this.code = PREFIX + code;
        this.desc = desc;
    }

    public static String getDesc(String errorCode) {
        for (ErrorDef bussErrorCode : ErrorDef.values()) {
            if (bussErrorCode.code.equals(errorCode)) {
                return bussErrorCode.desc;
            }
        }
        return errorCode;
    }
}
